<?php
// $cpage_locale=new cLocale("global_html.inc",$_SESSION["guser_preferences"]["language"]);
/***********************************************************************************************
        File Name                :        class_page.inc
        File Description        :        contains variables, functions dealing with the page layout
        Include Files        :        class_pgsql.inc
        Created By        :        S.Gnanavel
        Created On        :        14 March 2003
        Modified By        :        R.Lakshmi Narayanan
        Modified On        :        21 March 2003
***********************************************************************************************/

class cPage
        {
        // declaration starts here
        var $title;
        var $heading="";
        var $header_path="../";
        var $footer_path="../";
        var $errors="";
        var $logo=false;
        var $stylesheet="css/style128b.css";
        var $print_stylesheet="stylesheet/stylesheet_print.css";
        var $report;
        
	// end of declaration

        function cPage()
                {
                global $cpage_locale;
                $this->title=$cpage_locale->MESSAGE["global_html.inc"]["Title"];
                }

        /*****************************************************************************************
         Function Name         :doHeaderHtml
         No. of Arguments        :Nil
         Arguments                :Nil
         Action                        :starts the page layout as a table, sets the stylesheet and
                                                 displays the company logo in the first row and opens
                                                the next row with the first column
         Returns                        :Nil
         Created By                :S.Gnanavel
         Created On                :14 March 2003
         Modified By                :G.Sundar
         Modified On                :18 july 2006
        *****************************************************************************************/
        function doHeaderHtml($menu="")
                {
                global $cpage_locale;
                ?>
                <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                <html>
                <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                        <title><?php echo $this->title?></title>
                        <link rel='stylesheet' id='style-css'  href='<?php echo $this->header_path;?>css/style128b.css?ver=3.1' type='text/css' media='screen' />

<script type='text/javascript' src='<?php echo $this->header_path;?>js/jquery.min128b.js?ver=3.1'></script>
<script type='text/javascript' src='<?php echo $this->header_path;?>js/scripts128b.js?ver=3.1'></script>		
<script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/general_scripts.js"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EBEBEB;
}
-->
</style><div id="divTopLeft" style="position:absolute">
 		 		
<script type="text/javascript">var dmWorkPath="<?php echo
$this->header_path;?>includes/menu/";</script>
  		<script type="text/javascript" src="<?php echo $this->header_path;?>includes/menu/dmenu.js"></script>
</div>		
</head>

		<body onLoad="getFocus()">
		<!-- When window is resized reload the page for automatic adjustment of menu-->
                <!--<script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/reload.js"></script>-->
                <!-- menu script itself. you should not modify this file -->
        <script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/date-picker.js"></script>
		
                <!-- items structure. menu hierarchy and links are stored there -->
                <!-- files with geometry and styles structures -->

                <?php
		if($menu!="no")
			{
                if(!$_SESSION["guser_id"])
                        {
                        ?>
        <script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/discussion_menu_tpl.js"></script>
                        <?php
                        //include("global_files/discussion_menu.inc");
                        }
                else
                        {
                        if($_SESSION["gcompany_id"] > 1000)
                                {
                                // members using forum
                                ?>

        <script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/user_menu_tpl.js"></script>
                                <?php
                                }
                        else
                                {
                                // pure forum users
                                ?>
        <script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/discussion_user_menu_tpl.js"></script>
                         

       <?php
                                }
                        //include("contextmenus/user_menu.inc");
                        }
                if($_SESSION["gcompany_id"] > 1000 && $_SESSION["gcompany_id"] != 100002)
                        {
                        ?>
        <script language="JavaScript" src="<?php echo $this->header_path;?>jscripts/menu_tpl.js"></script>

                        <?php

                        include("global_files/menu.inc");
                        }

                ?>
                <div id="header-wrapper">
      <div id="header">
        <div id="logo"> <a href="#" class="logo"><img src="<?php echo $this->header_path;?>images/logo1.png" alt="" /></a> </div>
        <div class="nav">
          <ul id="menu-main-menu" class="menu">
            <li><a href="#">Master Entry</a>
                <ul class="sub-menu">
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_company_new.php">Master Company</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_city.php">Master City</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_state.php">Master State</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_port.php">Master Port</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_relationship.php?rel_type=buy">Master Buyer</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_relationship.php?rel_type=act">Master Account</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/master/master_company_contact.php">Company Contact</a></li>
                </ul>
            </li>
            <li><a href="#">Certificate Entry</a>
                <ul class="sub-menu">
                  <li><a href="<?php echo $this->header_path;?>lrp/documents/gsp.php">Generalised System Prefrences</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/documents/certificate_of_origin.php">Certificate Of Origin</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/documents/brc.php">Bank Realization Certificatate</a></li>
                </ul>
            </li>
            <li><a href="#">Reports</a>
                <ul class="sub-menu">
                  <li><a href="<?php echo $this->header_path;?>lrp/reports/report_page.php?report_id=3">Generalised System Prefrences</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/reports/report_page.php?report_id=4">Certificate Of Origin</a></li>
                  <li><a href="<?php echo $this->header_path;?>lrp/reports/report_page.php?report_id=5">Bank Realization Certificatate</a></li>
                </ul>
            </li>
            <li><a href="<?php echo $this->header_path;?>users/logout.php">Logout</a></li>
            <li><a href="#">User Guide</a></li>
            <!--<li><a href="#">Update</a></li>-->
            <li><a href="#">Contact</a></li>
          </ul>
        </div>
        <div class="clear"></div>
      </div>
    </div>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          
                  <tr>
                    <td><table width="100%" align="center" cellpadding="0" cellspacing="0">
                      <tbody>
                        <tr>
                          <td width="96%" colspan="3" align="center" bgcolor="#FFFFFF"><?php
                                if($logo)
                                        {
                                        $image=$this->header_path."logo.png"?>
                              <a href="<?php echo $this->header_path; echo "users/redirect.php";?>">
                              <?php
                                        }
                                else
                                        {
                                        if($_SESSION["gcompany_id"]!=1000 && $_SESSION["guser_company_name"])
                                                {
                                                $tri_image=$this->header_path."images/tri.jpg";
                                                ?>
                              <table border="0" width="100%" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td align="left"><?php
                                                echo "<h1>$_SESSION[guser_company_name]</h1>";
                                                ?>                                  </td>
                                  <td align="right" width="30%"><?php
                                                $company_id=$_SESSION["gcompany_id"];
                                                if ($_SESSION["guser_privilege"][$company_id])
                                                        {
                                                        $$_REQUEST["product_category_id"]="selected";
                                                        $$_REQUEST["type"]="selected";
                                                                                                               					}
                                                ?>                                  </td>
                                </tr>
                              </table>
                            <?php
                                                }
                                        else
                                                {
						?>
                         <?php
                                                }
                                        }
			}
				?>
                                <br>
                              </h1>
                            <!-- Javascript to set focus to the first non -hidden element of a form-->
                            <SCRIPT LANGUAGE="JavaScript">
                <!--
                function getFocus()
                        {
                        var form_name=document.forms[1];
                        // If form is there in a page
                        if(form_name)
                                {
                                for(i=0;i<form_name.elements.length;i++)
                                        {
                                        if (form_name.elements[i].type != "hidden")
                                                {
                                                form_name.elements[i].focus();
                                                return 1;
                                                }
                                        }
                                }
                        }
                -->
                                                </SCRIPT>
                              <?php
                }        // end of function doHeaderHtml


        /*****************************************************************************************
         Function Name         :doUserMenu
         No. of Arguments        :2
         Arguments                :($msg) optional variable to display the message to the user
                                  ($karma) optional variable to display the points scored by the user
         Action                        :displays the menu for the logged in users to send email,
                                                 to set preferences, to view messages etc., else
                                                displays the form to login
         Returns                        :Nil
         Created By                :S.Gnanavel
         Created On                :14 March 2003
         Modified By                :R.Lakshmi Narayanan
         Modified On                :21 March 2003
        *****************************************************************************************/
        function doUserMenu($msg="",$karma="",$msg_count="")        // function starts here
                {
                global $cpage_locale;
                // if the user is logged in displays a welcome message and the no of points if acquired
                if(!$_SESSION["guser_id"])
                        {
                        ?>
                              <br>
                              <?php
                        }
                else
                        {
                        ?>
                              <?php
                        }
                echo "<br />";
                }        // end of function doUserMenu


         /*****************************************************************************************
         Function Name         :doCentreHtml
         No. of Arguments        :Nil
         Arguments                :Nil
         Action                        :closes the first column of the second row and starts a new
                                                 column and displays the heading in the center.  If
                                                sub menu is given displays it next to the heading on the
                                                right hand side using the user defined function doSubMenu
         Returns                        :Nil
         Created By                :S.Gnanavel
         Created On                :14 March 2003
         Modified By                :R.Lakshmi Narayanan
         Modified On                :21 March 2003
        *****************************************************************************************/
        function doCentreHtml()                // function starts here
                {
                if($_SESSION["guser_id"])
                        {
                        ?>
                              <!-- displays the heading -->
                          
                              <h4><?php echo $this->heading ?></h4>
                            <?php
                        
                        }
                else
                        {
                        ?>
                              <!-- displays the heading -->
                              
                              <h4><?php echo $this->heading ?></h4>
                            <?php
                        }
                        ?>
                              <h4><?php echo $this->errors ?></h4>
                            <?php
                }        // end of function doCentreHtml


        /*****************************************************************************************
         Function Name         :doFooterHtml
         No. of Arguments        :Nil
         Arguments                :Nil
         Action                        :closes the second column and opens the next row and
                                                 displays the links to the pages dealing with the
                                                company information.
         Returns                        :Nil
         Created By                :S.Gnanavel
         Created On                :14 March 2003
         Modified By                :R.Lakshmi Narayanan
         Modified On                :21 March 2003
        *****************************************************************************************/
        function doFooterHtml()                // function starts here
                {
                $tri1_image=$this->header_path."images/tri1.jpg";
                $bar_image=$this->header_path."images/bar.jpg";
                ?>
                          <!--End of the centre cell--></td>
                        </tr>
                        <!--end of the page formatting table-->
                        <!--print the general links within the stylesheet class defined in the stylesheet-->
                      </tbody>
                    </table></td>
                  </tr>
                  <tr>
                    <td><?php
		global $startTime;

		list($usec, $sec) = explode(" ", microtime());
		$endTime=((float)$usec + (float)$sec);
		$time = $endTime - $startTime;
// 		echo "Took ".number_format($time,2)." seconds\n";
		?>
        <p>FOOTER</p></td>
                  </tr>
                </table>
		</body>
                </html>
                <?php
                }        // end of function doFooterHtml

        /*************************************************************************************************************************************

                Function Name   : doPrintHeader

                Arguments       : title of the page ($title),
                                stylesheet name ($stylesheet)

                Action          : prints the html header for printable pages

                Returns         : Nil

                Modified on     : Sep 02, 2002

                Modified by     : Siva Kumar

        ***************************************************************************************************************************************/

        function doPrintHeader()
                {
                //HTML header
                ?>
                <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                <html>
                <head>
                        <meta http-equiv="Content-Language" content="en-us">
                        <meta http-equiv="Content-Type" content="text/html; charset=iso8859-01">
                        <title><?php echo $this->title?></title>
                        <link rel="stylesheet" type="text/css" href="<?php echo ($this->header_path); echo
$this->print_stylesheet?>">
                </head>
                <body >
                <?php
		echo "<h2>$_SESSION[guser_company_name]</h2>";
                echo "<h4 align=\"center\">$this->title </h4>";
                }

        /*************************************************************************************************************************************

                Function Name    : doPrintFooter

                Arguments       :

                Action          : Footer for printable report

                Returns         :

                Modified on     : Sep 02, 2002

                Modified by     : R.Lakshmi Narayanan

        ***************************************************************************************************************************************/

	
        function doPrintFooter()
                {
                ?>
		<hr>
		<font size=1 family="verdana">.</font>
                </body>
                </html>
                <?php
                }
                
        function doPrintUpperHtml()
                {
                if ($_GET["rtype"] == "p")
                        {
                        $this->doPrintHeader();
                        }

                else
                        {
                        $this->doHeaderHtml();
                        $this->doUserMenu();
                        $this->doCentreHtml();
                        }
                }
                
        function doPrintBottomHtml()
                {
                if ($_GET["rtype"] == "p")
                        {
                        $this->doPrintFooter();        
                        }
                else        
                        {
                        $this->report->showPrintableReportLink();
                        $this->doFooterHtml();
                        }
                }                
        }

?>
